//
// Stopwatch.cs
//
// Copyright (C) 2008 Lukas Lipka <lukaslipka@gmail.com>
//

using System;

namespace Dashboard.Util {

	public class Stopwatch {
		
		private DateTime start;
		private double duration;

		public Stopwatch ()
		{
		}

		public void Start ()
		{
			this.start = DateTime.Now;
		}

		public void Stop ()
		{
			TimeSpan length = DateTime.Now - start;
			this.duration = length.TotalSeconds;
		}

		public void Reset ()
		{
			this.duration = 0;
			Start ();
		}

		public double Duration {
			get { return duration; }
		}

		public override string ToString ()
		{
			return String.Format ("{0:0.00}s", duration);
		}
	}
}
